package zsh.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import zsh.domain.Brand;
import zsh.mapper.brandMapper;

import java.util.List;

@Service
public class BrandServiceImpl implements IBrandService {

    @Autowired
    private brandMapper brandMapper;

    @Override
    @Transactional
    public int addBrand(Brand brand) {
        return brandMapper.insert(brand);
    }

    @Override
    @Transactional
    public int deleteBrand(Integer id) {
        return brandMapper.deleteById(id);
    }

    @Override
    @Transactional
    public int updateBrand(Brand brand) {
        return brandMapper.update(brand);
    }

    @Override
    public Brand getBrandById(Integer id) {
        return brandMapper.selectById(id);
    }

    @Override
    public List<Brand> getAllBrands() {
        return brandMapper.selectAll();
    }
}